package c.x.jy.dao.dao;

import c.x.jy.dao.dto.FanEntityDto;
import c.x.jy.dao.entity.FanEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 大师粉丝表
 * 
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-05-25 10:46:12
 */
@Mapper
public interface FanDao extends BaseMapper<FanEntity> {

    @Select("select f.*,m.nickname fanName,m.headimgurl fanImage,t.nickname teacherName,m.headimgurl teacherImage from (t_fan f LEFT JOIN t_member m on f.fan_id=m.id) LEFT JOIN t_teacher t on f.teacher_id=t.id where f.teacher_id=${teacherId}")
    List<FanEntityDto> myRenmai(Long teacherId);


    @Select("SELECT t.nickname teacherName,m.headimgurl teacherImage, m1.nickname fanName,m1.headimgurl fanImage FROM `t_fan` f left join t_teacher t on t.id=f.teacher_id LEFT JOIN t_member m on m.id=t.member_id LEFT JOIN  t_member m1 on m1.id=f.fan_id where f.fan_id=${memberId}")
    List<FanEntityDto> myGuanzhu(Long memberId);

    @Select("select f.*,m.nickname as fanName,t.nickname as teacherName from (t_fan f LEFT JOIN t_member m on m.id=f.fan_id) LEFT JOIN t_teacher t on t.id=f.teacher_id     ${ew.customSqlSegment} ")
    IPage<FanEntityDto> listforweb(IPage<FanEntityDto> page,@Param(Constants.WRAPPER)  QueryWrapper<FanEntity> query);
}

